# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=nftlb
pkgver=1.0.8
pkgrel=0
pkgdesc="nftables load balancer"
url="https://github.com/zevenet/nftlb"
arch="all"
license="AGPL-3.0"
checkdepends="bash"
makedepends="autoconf automake jansson-dev libev-dev libmnl-dev libtool nftables-dev"
subpackages="$pkgname-openrc"
source="https://github.com/zevenet/nftlb/archive/v$pkgver/$pkgname-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	musl-fixes.patch
	"

prepare() {
	autoreconf -fi
	default_prepare
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var
	make
}

check() {
	# NOTE: It's not safe to run the provided tests on the builder.
	./src/nftlb --help 2>/dev/null || ./src/nftlb --help
}

package() {
	make install DESTDIR="$pkgdir"

	install -m 0755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -m 0644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="
f612b7065fb5011f1af34cabe0945b7b0c1479241b4673d86e2e97d06bffdfefcc5ca4ec3ad3752faa92862306ed8ad28754838236476fe9db88099bc389cf7c  nftlb-1.0.8.tar.gz
3e15dc73b21412d1504892ee1e550a00c895671069a32e9c80a38a7c68bc8988c44519bfb15f288e42a96047febfeb38eeffc534381d644f87ede859b23efe71  nftlb.initd
9a4384fe295203a80489ea2a61f0c4b9b8b2ac1be51c506b4ab5c3c9e76818a0cd18f6b372323ea84dcd0437e1224cd9be339c9463c3c8042e6c3e74e73ae360  nftlb.confd
d4ec17fc3fc64b75455d5cfc0e569407e764608e94a954047863b318db76797ba72eaf0dda6ea33ac8a9caaa514746e80fb723a4797f874b6d78ac5dbd6834a3  musl-fixes.patch
"
